#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

void inPlace(int A[], int len, int &size)
{
    int j = 0, i = 0;
    while(i < len) {
	int cur = A[i];
        while(++i < len && A[i] == cur);
	A[j++] = cur;
    }
    size = j;
    return;
}


int main(int argc, char **argv)
{
    int A[] = {1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 6, 6, 6,7,7,7,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9};
    int size = 0;
    inPlace(A, sizeof(A)/sizeof(int), size);
    for (int i = 0; i < size; i++) 
	cout << A[i] << " ";
}
